<template>
  <div id="app">
    <transition :name="fadeName">
      <router-view class="page" />
    </transition>
    <div class="foot">
      <router-link to="/">首页</router-link>
      <router-link to="/about">分类</router-link>
      <router-link to="/cart">购物车</router-link>
      <router-link to="/user">我的</router-link>
    </div>
  </div>
</template>
<script>
export default {
  data() {
    return {
      fadeName: "fade",
    };
  },
  watch: {
    $route(newVal, oldVal) {
      // console.log(newVal);
      // console.log(oldVal);
      if (oldVal.meta.num - newVal.meta.num > 0) {
        this.fadeName = "back";
      } else {
        this.fadeName = "fade";
      }
    },
  },
};
</script>
<style lang="scss">
html,
body,
#app {
  height: 100%;
  overflow: hidden;
  position: relative;
}

* {
  padding: 0;
  margin: 0;
}

.page {
  height: calc(100% - 50px);
  position: absolute;
  top: 0px;
  left: 0px;
  width: 100%;
}

.foot {
  position: absolute;
  bottom: 0px;
  left: 0px;
  width: 100%;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: space-around;
}

.fade-enter {
  transform: rotate(360deg) scale(0.1);
  // zoom: 10%;
}

.fade-leave-to {
  opacity: 0;
}

.fade-enter-active,
.fade-leave-active,
.back-enter-active,
.back-leave-active {
  transition: all 0.5s linear;
}

.back-enter {
  transform: translateX(-100%);
}

.back-leave-to {
  transform: translateX(100%);
}
</style>
